﻿var options_pie;
var options_cloumn
var options_line;
var orgCode, startDate, endDate,selectedDateTime;
var pieUrl, chartUrl, hrefType, columns, gridUrl,satType,patientType, medExpType, xUnit="",yUnit, clickType,dateFmt,nowDate;
function initData() {
	$("#org").combobox("select", "全部");
	initDateTime();
}
function initDateTime(){
	var fromDate = new Date();
	nowDate = new Date();
	fromDate.setDate(nowDate.getDate() - 6);
	$("#fromDate").val(fromDate.getFullYear() + "-" + (fromDate.getMonth() + 1) + "-"
					+ fromDate.getDate());
	$("#endDate").val(nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-"
					+ nowDate.getDate());
}

function setData() {
	orgCode = $("#org").combobox("getValue").split('-')[0];
	if (orgCode == "全部" || orgCode == "000")
		orgCode = "";
	startDate = $("#fromDate").val();
	endDate = $("#endDate").val();
	var days=startDate.split('-');
	if(days.length==2){
		startDate=days[1];
		endDate=endDate.split('-')[1];
	}
}
function setChart() {
	options_cloumn = {
		chart : {
			renderTo : 'container_column',
			type : 'column',
			backgroundColor : '#fff',
			marginTop:25,
			marginLeft:45,
			plotBackgroundColor:'#FFFFFF',
			plotBorderColor:'#FFFFFF',
			plotBorderWidth:0,
			borderWidth : 0
		},
		title : {text : ''},
		xAxis : {
        	lineColor:'#FFFFFF',
			tickColor: '#C0D0E0',
			categories : []
		},
		yAxis : {
			title : {text : '单位:'+yUnit,
			  align: 'high',
            offset: 0,
            rotation: 0,
            y: -8,
          	x:25,
          	style: {color: 'red'}
			},
			lineColor:'#C0C0C0',
			plotLines : [ {
				value : 0,
				width : 1,
				color: 'red'
			} ],
			 tickColor: '#C0D0E0'
		},
		credits : {
			enabled : false
		},
		tooltip : {
			formatter : function() {
			if(hrefType==2)
				return '<b>' + this.series.name +' '  + this.x+xUnit + ':</b> '
						+ Highcharts.numberFormat(this.y,yUnit=='人'?0:2,'.',',') + yUnit;
			else
				return '<b>' + this.series.name +' '  + this.x+xUnit + ':</b> '
						+ Highcharts.numberFormat(this.y,yUnit=='人'?0:2,'.',',') + yUnit+'<br><b>总量:'+this.x+xUnit +':</b>'+
						Highcharts.numberFormat(this.total,yUnit=='人'?0:2,'.',',')+yUnit;
			}
		},
		       plotOptions: {
                column: {
                    stacking: hrefType==2?'':'normal',
                    dataLabels: {
                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                    }
                }
            },
		legend : {
			layout : 'vertical',
			align : 'right',
			verticalAlign : 'top',
			x : 1,
			y : 15,
			borderWidth : 0,
			itemMarginTop : 15
		},
		series : []
	};

	options_line = {
		chart : {
			renderTo : 'container_line',
			type : 'line',
			backgroundColor : '#FFFFFF',
			marginTop:25,
			marginLeft:45,
			plotBackgroundColor:'#FFFFFF',
			plotBorderColor:'#FFFFFF',
			plotBorderWidth:0,
			borderWidth : 0
			
		},
		title : {text : ''},
		xAxis : {
			categories : [],
			lineColor:'#C0D0E0',
			tickColor: '#C0D0E0'
				
		},
			yAxis : {
			title : {text : '单位:'+yUnit,
			  align: 'high',
            offset: 0,
            rotation: 0,
            y: -8,
          	x:25,
          	style: {color: 'red'}
			},
			lineColor:'#C0C0C0',
			plotLines : [ {
				value : 0,
				width : 1,
				color: 'red'
			} ],
			 tickColor: '#C0D0E0'
		},
		credits : {
			enabled : false
		},
		tooltip : {
			formatter : function() {
				return '<b>' + this.series.name + '</b>' + this.x+xUnit + ': '
						+ Highcharts.numberFormat(this.y,2,'.',',') + yUnit;
			}
		},
		legend : {
			layout : 'vertical',
			align : 'right',
			verticalAlign : 'top',
			x : 1,
			y : 15,
			borderWidth : 0,
			itemMarginTop : 15
		},
		series : []
	};

	options_pie = {
		chart : {
			renderTo : 'container_pie',
			plotBackgroundColor : null,
			defaultSeriesType : 'pie',
			plotBorderWidth : null,
			plotShadow : false,
			//marginTop:-20,
			marginLeft:-20,
			backgroundColor : '#fff',
			borderWidth : 0
		},
		title : {
			text : ''
		},
		tooltip : {
			formatter : function() {
				return '<b>' + this.point.name + '</b>:' + Highcharts.numberFormat(this.y,yUnit=='人'?0:2,'.',',') + yUnit+'<br><b>比例</b>:'+
				Highcharts.numberFormat(this.percentage, 2)+' %';
			}
		},
		credits : {
			enabled : false
		},
		legend : {
			layout : 'vertical',
			align : 'right',
			itemMarginright : 5,
			verticalAlign : 'bottom',
			x : 3,
			y : -30,
			floating : true,
			shadow : true,
			itemMarginTop : 15,
			borderWidth : 0
		},
		plotOptions : {
			pie : {
				allowPointSelect : true, //点击切换
				cursor : 'pointer',
				
				dataLabels : {
					enabled : true,
					//color : Highcharts.theme.textColor || '#fff',
					//connectorColor : Highcharts.theme.textColor || '#fff',
					//rotation:5,
					formatter : function() {
						return  Highcharts.numberFormat(this.percentage, 2)+' %';
				},
				distance : 15,
				style : {
					fontWeight : 'bold'
				}
				},
				showInLegend : true
			}
		},
		series : [ {
			data : []
		} ]
	};

}
function setChartData() {
	switch (hrefType) {
	case 1: {
		pieUrl = "ehr/clinicSat_getSumPie.action";
		chartUrl = "ehr/clinicSat_getSumChart.action";
		break;
	}
	case 2: {
		pieUrl = "ehr/hosNumSat_getSumPie.action";
		chartUrl = "ehr/hosNumSat_getSumChart.action";
		break;
	}
	case 3: {//门诊费用统计[按病人类型进行统计]satType,patientType,medExpType
		if (medExpType == null) {
			pieUrl = "ehr/medExpSat_getSumPieByPatient.action?satType=1&patientType="
					+ patientType;
			chartUrl = "ehr/medExpSat_getSumChartByPaitent.action?satType=1&patientType="
					+ patientType;
		} else {
			pieUrl = "ehr/medExpSat_getSumPieByMedExp.action?satType=1&medExpType="
					+ medExpType;
			chartUrl = "ehr/medExpSat_getSumChartByMedExp.action?satType=1&medExpType="
					+ medExpType;
		}
		break;
	}
	case 4: {//住院费用统计[按病人类型进行统计]satType,patientType,medExpType
		if (medExpType == null) {
			pieUrl = "ehr/medExpSat_getSumPieByPatient.action?satType=2&patientType="
					+ patientType;
			chartUrl = "ehr/medExpSat_getSumChartByPaitent.action?satType=2&patientType="
					+ patientType;
		} else {
			pieUrl = "ehr/medExpSat_getSumPieByMedExp.action?satType=2&medExpType="
					+ medExpType;
			chartUrl = "ehr/medExpSat_getSumChartByMedExp.action?satType=2&medExpType="
					+ medExpType;
		}
		break;
	}
	case 5: {
		pieUrl = "ehr/medExpSat_getSumPieByClinic.action";
		chartUrl = "ehr/medExpSat_getSumChartByClinic.action";
		break;
	}
	case 6: {
		pieUrl = "ehr/medExpSat_getSumPieByHospital.action";
		chartUrl = "ehr/medExpSat_getSumChartByHospital.action";
		break;
	}

	}

	$.getJSON(pieUrl, {
		orgCode : orgCode,
		startDate : startDate,
		endDate : endDate
	}, function(data) {
		if(data==null){
			$.messager.alert('提示'
					, '<font color="red" ><b>选择的上报医院或统计时间不存在数据</b></font>','warning');
			$("#container_pie").html("");
			}
		else{
			options_pie.series[0].data = data;
			new Highcharts.Chart(options_pie);
			var title=$("#left_title").html();
			if(title!='出入院人次'){
		   		if (title=='门诊人次')
		   			$("#totalUnit").html("总人次:");
		   		else if (title=='门诊费用'||title=='住院费用')
		   			$("#totalUnit").html("总费用:");
		   		else if(title=='门诊人均费用')
		   			$("#totalUnit").html("次均门诊费用:");
		   		else
		   			$("#totalUnit").html("次均住院费用:");
		   		var number=data[0].y+data[1].y;
		   		if(yUnit=='元'&&title.length==4){
		   			if(number>10000){
		   				number=number/10000;
		   				$("#totalSpan").html(number_format(number,2)+'万'+yUnit);
		   			}else
		   				$("#totalSpan").html(number_format(number,2)+yUnit);
		   		
		   		}else  //单位为人
		   			$("#totalSpan").html(number_format(data[0].y+data[1].y,0)+yUnit);
				}else{
					$("#totalUnit").html("");
					$("#totalSpan").html("");
				}
			}
	});
	$.getJSON(chartUrl, {
		orgCode : orgCode,
		startDate : startDate,
		endDate : endDate
	}, function(data) {
		if(data!=null){
			options_cloumn.series = data.series;
			options_cloumn.xAxis.categories = data.categories;
			options_line.series = data.series;
			options_line.xAxis.categories = data.categories;
			new Highcharts.Chart(options_cloumn);
			new Highcharts.Chart(options_line);
		}else{
			$("#container_line").html("");
			$("#container_column").html("");

			
		}
	});
}
/**数字格式化
* src 数据源
* decimal 小数位
* sep 千分位分格符
* per 小数点符
**/
function number_format(src, decimal, sep, per){
  var nbr,cnt,ints,dec,temp;
  switch (typeof(src)){
    case "string":
      nbr=src;
      break;
    case "number": 
      nbr=src.toString();
      break;
    default:
      break;
  }
  ints=nbr.split(".")[0];
  dec=typeof(nbr.split(".")[1])=="undefined"?0:nbr.split(".")[1];
  cnt=Math.floor((ints.length-1)/3);
  if(!sep)
	  sep=",";
  if(!per)
	  per=".";
  for (var i=cnt;i>0;i--){
    ints=ints.substring(ints.length-i*3,0)+sep+ints.substring(ints.length-i*3,ints.length);
  }
  if (decimal>0) {
    if (dec.length>=decimal) {
    		
    		if(dec.substring(0,1)==0){//小数位起始位为0
    			dec=dec.substring(1,dec.length);
         		dec="0"+(Math.round(parseInt(dec)/Math.pow(10, (dec.length-decimal+1)))).toString().split(".")[0];
  			}else
  				 dec=(Math.round(parseInt(dec)/Math.pow(10, (dec.length-decimal)))).toString().split(".")[0];
    		
    } else {
      tmp=decimal-dec.length;
      for (var i=0;i<tmp;i++){
        dec=dec+"0";
      }
    }
   	 return ints+per+dec;
  } else {
    return ints;
  }
}

function setDataGridData() {
	switch (hrefType) {
	case 1: {
		gridUrl = "ehr/clinicSat_getSumList.action?startDate=" + startDate
				+ "&endDate=" + endDate + "&orgCode=" + orgCode;
				columns = [ [ {
			field : 'orgName',
			title : '机构名称',
			width : 120,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'opsNum',
			title : '门诊量',
			width : 30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'emergencyNum',
			title : '急诊量',
			width : 30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'totalNum',
			title : '总数量',
			width : 30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		},
		{
			field : 'repDate',
			title : '上报时间',
			width : 80,
			formatter : function(value, rowData, rowIndex) {
			if(value.length>4)
				return value.split(' ')[0];
			else if (value.length==4)
				return value+"年";
			else {
				if(value.substr(0,1)=="1")
					return value+"月";
				else rs.getString(3)
					return value.substr(1)+"月";
			}
			},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		} ] ];
		break;
	}
	case 2: {
		gridUrl = "ehr/hosNumSat_getSumList.action?startDate=" + startDate
				+ "&endDate=" + endDate + "&orgCode=" + orgCode;
		columns = [ [ {
			field : 'orgName',
			title : '机构名称',
			width : 120,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'totalNum',
			title : '床日数',
			width : 30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'inHosNum',
			title : '入院数',
			width : 30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'outHosNum',
			title : '出院数',
			width : 30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'repDate',
			title : '上报时间',
			width : 80,
			formatter : function(value, rowData, rowIndex) {
			if(value.length>4)
				return value.split(' ')[0];
			else if (value.length==4)
				return value+"年";
			else {
				if(value.substr(0,1)=="1")
					return value+"月";
				else 
					return value.substr(1)+"月";
			}
			},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		} ] ];
		break;
	}
	case 3: 
	case 4: 
			gridUrl = "ehr/medExpSat_getSumList.action?satType="+satType+"&startDate=" + startDate
						+ "&endDate=" + endDate + "&orgCode=" + orgCode+"&patientType="+ patientType+"&medExpType="+ medExpType;
			if(dateFmt=="yyyy-MM-dd"){
			columns = [ [ {
			field : 'orgName',
			title : '机构名称',
			width : 120,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'ctype',
			title : '统计类别',
			width : 30,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '门诊';
				else
					return '住院';
				}
		}, {
			field : 'ptype',
			title : '病人类别',
			width : 50,
			sortable : true,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '自费';
				else if(value==2)
					return '医保';
				else if (value==3)
					return '合保';
				},
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'etype',
			title : '费用类别',
			width : 50,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '诊疗';
				else if(value==2)
					return '药品';
				else if (value==9)
					return '其它';
				},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		},
		{
			field:'expName',
			title : '费用名称',
			width:80,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		},
		{
			field:'expCount',
			title : '费用金额',
			width:30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}
		, {
			field : 'repDate',
			title : '上报时间',
			width : 80,
			formatter : function(value, rowData, rowIndex) {
			if(value.length>4)
				return value.split(' ')[0];
			else if (value.length==4)
				return value+"年";
			else {
				if(value.substr(0,1)=="1")
					return value+"月";
				else 
					return value.substr(1)+"月";
			}
			},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		} ] ];
			}else{
				columns = [ [ {
			field : 'orgName',
			title : '机构名称',
			width : 120,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'ctype',
			title : '统计类别',
			width : 30,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '门诊';
				else
					return '住院';
				}
		}, {
			field : 'ptype',
			title : '病人类别',
			width : 50,
			sortable : true,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '自费';
				else if(value==2)
					return '医保';
				else if (value==3)
					return '合保';
				},
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'etype',
			title : '费用类别',
			width : 50,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '诊疗';
				else if(value==2)
					return '药品';
				else if (value==9)
					return '其它';
				},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		},
		{
			field:'expCount',
			title : '费用金额',
			width:30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}
		, {
			field : 'repDate',
			title : '上报时间',
			width : 80,
			formatter : function(value, rowData, rowIndex) {
			if(value.length>4)
				return value.split(' ')[0];
			else if (value.length==4)
				return value+"年";
			else {
				if(value.substr(0,1)=="1")
					return value+"月";
				else 
					return value.substr(1)+"月";
			}
			},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		} ] ];
			}
		break;		
	
	case 5:{
		gridUrl = "ehr/medExpSat_getSumListByCLinic.action?startDate=" + startDate
				+ "&endDate=" + endDate + "&orgCode=" + orgCode;
		columns = [ [ {
			field : 'orgName',
			title : '机构名称',
			width : 120,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'etype',
			title : '费用类别',
			width : 50,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '诊疗';
				else if(value==2)
					return '药品';
				else if (value==9)
					return '其它';
				},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
				}
			},
			{
			field:'expPCTCount',
			title : '费用金额',
			width:30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'repDate',
			title : '上报时间',
			width : 80,
			formatter : function(value, rowData, rowIndex) {
			if(value.length>4)
				return value.split(' ')[0];
			else if (value.length==4)
				return value+"年";
			else {
				if(value.substr(0,1)=="1")
					return value+"月";
				else 
					return value.substr(1)+"月";
			}
			},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		} ] ];
		break;
	}
	case 6:{
		gridUrl = "ehr/medExpSat_getSumListByHospital.action?startDate=" + startDate
				+ "&endDate=" + endDate + "&orgCode=" + orgCode;
		columns = [ [ {
			field : 'orgName',
			title : '机构名称',
			width : 120,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'etype',
			title : '费用类别',
			width : 50,
			formatter : function(value, rowData, rowIndex) {
				if(value==1)	
					return '诊疗';
				else if(value==2)
					return '药品';
				else if (value==9)
					return '其它';
				},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
				}
			},
			{
			field:'expPCTCount',
			title : '费用金额',
			width:30,
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		}, {
			field : 'repDate',
			title : '上报时间',
			width : 80,
			formatter : function(value, rowData, rowIndex) {
			if(value.length>4)
				return value.split(' ')[0];
			else if (value.length==4)
				return value+"年";
			else {
				if(value.substr(0,1)=="1")
					return value+"月";
				else 
					return value.substr(1)+"月";
			}
			},
			sortable : true,
			sorter : function(a, b) {
				return (a > b ? 1 : -1);
			}
		} ] ];
		break;
	}
	}
	var url = $('#datagrid').datagrid( {
		url : gridUrl,
		nowrap : false,
		striped : true,
		remoteSort: false,
		collapsible : true,
		pagination : true,
		rownumbers : true,
		pagination : true,
		fit : false,
		idField : 'orgCode',
		fitColumns : true,
		nowrap : false,
		frozenColumns : [ [ {
			title : 'orgCode',
			field : 'orgCode',
			width : 50,
			hidden : true
		} ] ],
		columns : columns
	});
}

function search() {
	if(selectedDateTime==2){//选择月度
		if($("#fromDate").val().substring(0,4)==$("#endDate").val().substring(0,4))//选择月度时年份相同
		{
			showData();
		}else{
				$.messager.alert('提示'
					, '选择月度时年份必须相同!','warning');
				
			return;
		}
	}else{
			showData();
	}
	
}
function showData() {

	setData();
	$("#startDateSpan").html(startDate+xUnit);
	$("#endDateSpan").html(endDate+xUnit);
	$("#depInfo").html($("#org").combobox('getText'));
		
    setChart();
	setChartData();
	setDataGridData()
}
$(function() {
	dateFmt="yyyy-MM-dd";
	$("input[name='rad']").change(
	function() {
	var selectedvalue = $("input[name='rad']:checked").val();
	switch (selectedvalue){
	case "1":
		dateFmt="yyyy-MM-dd";
		selectedDateTime=1;
		if($("#fromDate").val.length!=10){
			initDateTime();
		}
		xUnit="";
		break;
	case "2":
		dateFmt="yyyy-MM";
		selectedDateTime=2;
		$("#fromDate").val(nowDate.getFullYear()+"-"+"0"+(nowDate.getMonth()));
		$("#endDate").val(nowDate.getFullYear()+"-"+"0"+(nowDate.getMonth()+1));
		xUnit="月";
		break;
	case "3":
		dateFmt="yyyy";
		selectedDateTime=3;
		xUnit="年";
		$("#fromDate").val(nowDate.getFullYear());
		$("#endDate").val(nowDate.getFullYear());
		break;
	}
	});
	hrefType = 1;
	yUnit = "人";
	$("#org").combobox( {
		url : "ehr/clinicSat_getOrg.action",
		valueField : "key",
		textField : "value",
		editable : false
	});
	initData();
	showData();

});

//门诊量
function clinicSat() {
    $('#main-nav').css('display', 'none');
	$("#left_title").html("门诊人次");
	$("#crumb").html("<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span class='on'>门诊量</span>");
	$("#Rtitle1").html("门诊人次统计");
	$("#Rtitle2").html("门诊人次趋势图");
	$("#Rtitle3").html("门诊人次直方图");
	hrefType = 1;//门诊量统计
	yUnit = "人";
	showData();
}
//住院量
function hosNumSat() {
    $('#main-nav').css('display', 'none');
	$("#left_title").html("出入院人次");
	$("#crumb").html( "<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span class='on'>住院量</span>");
	$("#Rtitle1").html("出入院人次统计");
	$("#Rtitle2").html("出入院人次趋势图");
	$("#Rtitle3").html( "出入院人次直方图");
	hrefType = 2;//住院量统计
	yUnit = "人";
	showData();
}
//门诊费用
function clinicExpSat(obj, objType) {
    $('#main-nav').css('display', 'block');
	$("#left_title").html( "门诊费用");  
	if (objType == "1") {
		$("#crumb").html("<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span>门诊费用</span><span>&gt;</span><span class='on'>按病人类别统计</span>");
	}
	else {
	$("#crumb").html("<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span>门诊费用</span><span>&gt;</span><span class='on'>按费用类别统计</span>");
	}
		$("#Rtitle1").html("门诊费用统计");
	$("#Rtitle2").html("门诊费用趋势图");
	$("#Rtitle3").html( "门诊费用直方图");
	

	$("#main-nav li a").siblings().find("a").removeClass('current');
	hrefType = 3;//门诊费用统计
	yUnit = "元";
	satType=1;//统计类别为门诊
	clickType = 1;//按门诊费用进行统计
	if (objType == 1) { //按病人类别进行统计	
		patientType = obj;
		medExpType = null;
	} else {//按费用类型进行统计
		medExpType = obj;
		patientType = null;
	}
	showData();
}
//住院费用
function hosExpSat(obj, objType) {
    $('#main-nav').css('display', 'block');
	$("#left_title").html( "住院费用");  
		if (objType == "1") {
	$("#crumb").html( "<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span>住院费用</span><span>&gt;</span><span class='on'>按病人类别统计</span>");
		}
	else {
	$("#crumb").html( "<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span>住院费用</span><span>&gt;</span><span class='on'>按费用类别统计</span>");
		};
	$("#Rtitle1").html("住院费用统计");
	$("#Rtitle2").html( "住院费用趋势图");
	$("#Rtitle3").html( "住院费用直方图");
	$("#main-nav li a").siblings().find("a").removeClass('current');
	hrefType = 4;//住院费用统计
	satType=2;//统计类别为住院
	clickType = 2//按住院费用进行统计
	if (objType == 1) { //按病人类别进行统计	
		patientType = obj;
		medExpType = null;
	} else {//按费用类型进行统计
		medExpType = obj;
		patientType = null;
	}
	yUnit = "元";
	showData();
}
//门诊人均费用
function clinicPCTExpSat() {
    $('#main-nav').css('display', 'none');
	$("#left_title").html("门诊人均费用");  
	$("#crumb").html( "<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span class='on'>门诊人均费用</span>");
	$("#Rtitle1").html( "门诊人均费用统计");
	$("#Rtitle2").html( "门诊人均费用趋势图");
	$("#Rtitle3").html( "门诊人均费用直方图");
	hrefType = 5;//门诊人均费用统计
	yUnit = "元";
	showData();
}
//住院人均费用
function hostPCTExpSat() {
    $('#main-nav').css('display', 'none');
	$("#left_title").html( "住院人均费用");  
	$("#crumb").html("<label>您当前的位置：</label><span>业务统计</span><span>&gt;</span><span class='on'>住院人均费用</span>");
	$("#Rtitle1").html("住院人均费用统计");
	$("#Rtitle2").html("住院人均费用趋势图");
	$("#Rtitle3").html("住院人均费用直方图");
	hrefType = 6;//住院人均费用统计
	yUnit = "元";
	showData();
}
//按病人类型进行统计
function satByPatient(obj, objType) {
	switch (clickType) {
	case 1: {//点击的上级菜单是门诊费用
		clinicExpSat(obj, objType);
		break;
	}
	case 2:///点击的上级菜单是住院费用
		hosExpSat(obj, objType);
		break;
	}
}
//按费用类型统计
function satByMedExp(obj, objType) {
	satByPatient(obj, objType)
}
function MyWdatePicker(){
	WdatePicker({readOnly:true,minDate:'2000-1-1',lang:'zh-cn',dateFmt:dateFmt });
}

function outlogin(){
	$.ajax( {
		url : "logon_logout.action",
		type : "POST",
		dataType : "json",
		success : function(data) {
			try{
				var url = "login.jsp";
				if (data.requestUri != null)
					url = data.requestUri;
				openWin(url);
			}catch(e){
				//openWin("login.jsp");
				alert(e);
			}
		},
		error:function(msg){
			alert(msg.responsetext);}
		});
}
function openWin(url){
    window.location.href=url;
}
function GetRequest() { 
   var url = location.search; //获取url中"?"符后的字串 
   var theRequest = new Object(); 
   if (url.indexOf("?") != -1) { 
      var str = url.substr(1); 
      strs = str.split("&"); 
      for(var i = 0; i < strs.length; i ++) { 
         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); 
      } 
   } 
   return theRequest; 
} 
